package com.woniu.user.controller;

import com.woniu.common.result.Result;
import com.woniu.common.entity.dto.LoginDto;
import com.woniu.common.entity.dto.RegisterDto;
import com.woniu.common.entity.vo.LoginVo;
import com.woniu.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mane
 * @since 2025-03-28
 */
@RestController
@RequestMapping("/api/user")
public class UserController {

    @Autowired
    private IUserService userService;

    @PostMapping("/register")
    public Result register(@RequestBody RegisterDto registerDto) {
        userService.register(registerDto);
        return Result.success("注册成功",null);
    }

    @PostMapping("/login")
    public Result login(@RequestBody LoginDto loginDto) {
        LoginVo loginVo = userService.login(loginDto);
        return Result.success(loginVo);
    }
}
